<template>
	<view v-if="pageApiObj" :style="objColor">
		<customer />
		<!-- homeSub/pages/siteDetail/siteDetail.wxml -->
		<view class="sitePage">
			<!-- 站点信息 -->
			<view class="siteDetail">
				<view class="title">{{ siteItemData.name }}</view>
				 <!-- 自由车队价 显示 -->
				<view class="price_view" style="margin-left: 0;" v-if="siteItemData.freeDomDiscountRate">
                <view class="img_view_831_bg">
                  <image
                    class="v_icon"
                    src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/bgTag/icon_th.png"
                    mode="scaleToFill"
                  />
                  <view class="v_text" style="background: #fff;">
                    <text>服务费可享受{{ siteItemData.freeDomDiscountRate / 10 }}折</text>
                  </view>
                </view>
                
              </view>
				<!-- <view class="tagList">
                    <view
                        class="tag_item"
                        :style="item.color == 'rgba(96, 98, 102, 0.06)' ? 'color:#909399;' + 'background:' + item.color + ';' : 'color:#1487FA;' + 'background:' + item.color + ';'"
                        v-if="item.name"
                        v-for="(item, index) in siteItemData.stationLabel"
                        :key="index"
                    >
                        {{ item.name }}
                    </view>
                </view> -->
				<!-- 	<view class="siteTime" v-if="siteItemData.timeList.length">
				    <view class="showTime" >
				        {{ siteItemData.timeList[0]==='全天开放'? '全天开放':'分时段开放'}}
				    </view>
				</view> -->

				<!-- :style="{padding:(index1==0&&item.bright != 1?'0rpx 16rpx 0 0':'6rpx 16rpx')}" -->
				<!-- 标签 -->
				<view v-if="siteItemData.tagList && siteItemData.tagList.length" class="tagList">
					<view v-for="(item, index1) in siteItemData.tagList" :key="index1" class="tagCon">
						<view
							:key="index1"
							class="tag"
							:class="[item.bright == 1 ? 'tag1' : 'tag2']"
							style="display: inline"
							:style="{ padding: index1 == 0 && item.bright != 1 ? '0rpx 16rpx 0 0' : '6rpx 16rpx' }"
						>
							<text>{{ item.tagName }}</text>
						</view>
						<text v-if="siteItemData.tagList.length - 1 != index1 && item.bright != 1" class="tagDivision" />
					</view>
				</view>

				<scroll-view v-if="siteItemData.picArr.length > 0" class="siteImg" :scroll-x="true">
					<view class="view_list">
						<view v-for="(item, index) in siteItemData.picArr" :key="index">
							<image class="mypic" :data-index="index" :src="item.url" @tap="seeImg" />
						</view>
					</view>
				</scroll-view>

				<view v-if="siteItemData.timeList[0] != '全天开放'" class="timeListCon">
					<image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/time.png" />
					<text v-for="(item, index) in siteItemData.timeList.slice(1)" :key="index" class="timeListText">
						{{ item }}
						<text v-if="index + 1 < siteItemData.timeList.slice(1).length">,</text>
					</text>
				</view>

				<view class="info">
					<view class="address">
						<image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/add.png" />
						{{ siteItemData.street }}
					</view>
					<!-- <view class="item" @tap="goNearbyStations" :data-name="siteItemData.street">
                        附近站点
                        <image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/charg.png"></image>
                    </view>
                    <view class="item">|</view> -->
					<view
						v-if="siteItemData.distance != null"
						class="item"
						:data-latitude="siteItemData.latitude"
						:data-longitude="siteItemData.longitude"
						:data-name="siteItemData.name"
						:data-street="siteItemData.street"
						@tap.stop.prevent="goAddress"
					>
						{{ siteItemData.distance }}km
						<image
							class="img"
							mode="aspectFill"
							:src="
								(otherIconListSync[0] && otherIconListSync[0].icon) ||
								'https://oos-cn.ctyunapi.cn/front-end/static/static/Navigation.png'
							"
						/>
					</view>
					<view v-if="siteItemData.distance == null" class="item">未授权定位</view>
				</view>
				<view v-if="siteItemData.notice" class="notice">
					<image
						class="img"
						:src="
							sellerNo == 'jw'
								? 'https://oos-cn.ctyunapi.cn/front-end/static/mine/images/notice-blue.png'
								: 'https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/notice.png'
						"
					/>
					<scroll-view class="scrollIsf">
						<!-- 内容 start -->
						<view :class="'user-content-view ' + (isF ? 'hide' : 'show')">
							<text class="user-content">{{ siteItemData.notice ? siteItemData.notice : '暂无' }}</text>
						</view>
						<!-- 内容 end -->
						<!-- 展开 收起 strat -->
						<view v-if="siteItemData.noticeStatus" class="state" @tap="change">{{ isF ? '展开' : '收起' }}</view>
						<!-- 展开 收起  end -->
					</scroll-view>
				</view>
			</view>
			<!-- 价格信息 -->
			<view class="sitePrice">
				<!-- <view class="priceInfo">
                    <view>价格信息</view>
                    <view class="txt" @tap="goPriceDetail" v-if="isToken">
                        价格详情
                        <image class="txtImg" :src="sellerNo=='jw'?'https://oos-cn.ctyunapi.cn/front-end/static/mine/images/turn-blue.png':'https://oos-cn.ctyunapi.cn/front-end/static/cartoon/turn_act.png'"></image>
                    </view>
                </view> -->

				<!-- 移动端优化 -->
				<view class="priceInfo">
					<!-- #V2G功能 -->
					<view>{{ isV2GOption ? '充电费用信息' : '费用信息' }}</view>
					<view class="txt" @tap="goPriceDetail()">
						终端列表
						<uni-icons class="txticon" type="right" size="18" :color="objColor2.textColor"></uni-icons>
					</view>
				</view>

				<!-- 超 -->
				<view v-if="siteItemData.gunPriceInfo.superItem" class="exceed">
					<gunPriceInfo gunType="superItem" :siteItemData="siteItemData" />
					<view class="price-btn" @tap="pricePopupVisible(siteItemData.gunPriceInfo.superItem.gunId)">价格详情</view>
				</view>
				<!-- 快 -->
				<view v-if="siteItemData.gunPriceInfo.fastItem" class="fast">
					<gunPriceInfo gunType="fastItem" :siteItemData="siteItemData" />
					<view class="price-btn" @tap="pricePopupVisible(siteItemData.gunPriceInfo.fastItem.gunId)">价格详情</view>
				</view>
				<!-- 慢 -->
				<view v-if="siteItemData.gunPriceInfo.slowItem" class="slow">
					<gunPriceInfo gunType="slowItem" :siteItemData="siteItemData" />
					<view class="price-btn" @tap="pricePopupVisible(siteItemData.gunPriceInfo.slowItem.gunId)">价格详情</view>
				</view>

				<!-- 优惠说明 -->
				<view v-if="isToken" class="explain">
					<view class="txt1">优惠说明</view>
					<view
						v-if="!siteItemData.hasCoupons || ((memberType == 1 || memberType == 2) && siteItemData.hasCoupons)"
						class="txt2"
					>
						暂无可适用卡券
					</view>
					<view v-else class="disFlex" @tap="goCardVoucher">
						<view>有可适用卡券</view>
						<uni-icons class="explainIcon" type="right" size="18" :color="objColor2.textColor"></uni-icons>
					</view>
				</view>
				<view v-else class="explain">
					<view class="txt1">优惠说明</view>
					<view class="txt2">暂无可适用卡券</view>
				</view>

				<!-- #V2G功能 -->
				<template v-if="isV2GOption && siteItemData.gunPriceInfo.dischargeItem && memberType !=2">
					<view class="priceInfo" >
						<view>放电费用信息</view>
						<view class="txt" @tap="goPriceDetail(true)">
							终端列表
							<uni-icons class="txticon" type="right" size="18" :color="objColor2.textColor"></uni-icons>
					</view>
					</view>
					<view class="dischargeItem">
						<gunPriceInfo gunType="dischargeItem" :siteItemData='siteItemData'></gunPriceInfo>
						<view class="price-btn" @tap="pricePopupVisible(siteItemData.gunPriceInfo.dischargeItem.dischargeGunId, true)">价格详情</view>
					</view>
				</template>

				<!-- 停车费说明 -->
				<view v-if="siteItemData.parkingFeeDesc" class="explain2">
					<view class="txt1">停车费说明</view>
					<rich-text class="txt2" :nodes="siteItemData.parkingFeeDesc ? siteItemData.parkingFeeDesc : '暂无'" />
				</view>
			</view>

			<placeholPileList :detail="siteItemData" />
			<!-- 站点信息-info -->
			<view class="fotInfo">
				<view class="txt1">站点信息</view>
				<view class="txt2">
					支付方式
					<!-- #ifdef MP-WEIXIN || H5  -->
					<view class="type">微信支付</view>
					<!-- #endif -->
					<!-- #ifdef MP-ALIPAY  -->
					<view class="type">支付宝支付</view>
					<!-- #endif -->
				</view>
				<view class="txt2">
					资源类型
					<view class="type">{{ siteItemData.fastSlow }}</view>
				</view>
				<!-- <view class="txt2">
					运营单位
					<view class="type">{{ siteItemData.serviceOrg ? siteItemData.serviceOrg : '--' }}</view>
				</view> -->
				<!-- <view class="txt3">
                    客服电话
                    <view class="num" @tap="call">{{ siteItemData.managerPhone }}</view>
                </view> -->
			</view>

			<!-- 移动端优化 联系客服 -->
			<callPhone :siteItemData="siteItemData" />
		</view>
		<!-- 底部按钮操作 -->
		<view class="fot-do">
			<view class="disFlex">
				<view
					v-if="isToken"
					class="mode"
					:data-id="siteItemData.id"
					@tap="parseEventDynamicCode($event, siteItemData.isCollection ? 'cancelCollection' : 'collection')"
				>
					<image
						class="img"
						:src="
							siteItemData.isCollection
								? 'https://oos-cn.ctyunapi.cn/front-end/static/static/Collection_sel.png'
								: 'https://oos-cn.ctyunapi.cn/front-end/static/static/Collection.png'
						"
					/>
					<view>收藏</view>
				</view>
				<view v-if="isToken" class="mode" @tap="goProblemFeedback">
					<image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/refresh.png" />
					<view>反馈</view>
				</view>
				<view class="scanBtn1" style="margin-right: 24rpx" @click="goAppointment(siteItemData)" v-if="sellerNo=='szgx'">预约</view>
				<view
					:class="siteItemData.business ? 'scanBtn' : 'scanBtn1'"
					@tap="parseEventDynamicCode($event, siteItemData.business ? 'goScanCode' : 'showTip')"
				>
					扫码充电
				</view>
			</view>
		</view>

		<!-- 灰色遮罩，防止误触，可加可不加 -->
		<view v-show="showDialog" class="mask" />
		<!-- 自定义的弹窗 -->
		<view v-if="showDialog" class="windows">
			<view class="tips">确定取消收藏此站点吗</view>
			<view class="btn">
				<button class="Button1" @tap="onClick_1">
					<text class="word1">取消</text>
				</button>
				<button class="Button2" @tap="onClick_2">
					<text class="word2">确定</text>
				</button>
			</view>
		</view>
		<uni-popup ref="showCustomerPup" type="dialog">
			<!-- <view style="padding:100rpx 60rpx 60rpx;width:500rpx;border-radius: 16px;">
            <view class="dataInfo">联系客服：{{ siteItemData.managerPhone }}</view>
            <view class="dataInfo">工作时间：{{ siteItemData.serviceTime ? siteItemData.serviceTime : '暂无' }}</view>
            <view class="customerBtn">
                <view class="btn1" @tap="onCloseCustomer">取消</view>
                <view class="btn2" @tap="callCustomer">呼叫</view>
            </view>
			</view> -->
			<uni-popup-dialog
				cancelText="取消"
				confirmText="呼叫"
				title="温馨提示"
				type="info"
				@close="onCloseCustomer"
				@confirm="callCustomer"
			>
				<view>
					<view class="infoPopup">
						<view class="infoTitle">联系客服：</view>
						<text class="infoValue">{{ siteItemData.managerPhone }}</text>
					</view>
					<view class="infoPopup">
						<view class="infoTitle">工作时间：</view>
						{{ siteItemData.serviceTime ? siteItemData.serviceTime : '暂无' }}
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>

		<!-- 可用卡券 -->
		<u-popup
			closeable
			custom-style="border-radius:16rpx;margin:0 24rpx 37rpx;box-shadow: 4rpx 7rpx 20rpx 0rpx rgba(166,171,179,0.2400);padding:0 31rpx;background:#F5F7FA;overflow-y: scroll;"
			position="bottom"
			:show="cardCoupon"
			@close="cardCouponClose"
		>
			<view class="card_wrap">
				<view class="card_title">本站可用优惠券</view>
				<view class="card_list" style="max-height: 500rpx">
					<view
						v-for="(items, index) in cardCouponList"
						:key="index"
						class="card_item"
						:data-id="items.id"
						@tap.stop.prevent="toCardCoupons"
					>
						<image
							v-if="items.applyStationType == 1"
							class="card_bg"
							:src="
								items.picture
									? items.picture
									: 'http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/homeSub/images/line_bg.png'
							"
						/>

						<image
							v-if="items.applyStationType == 2 || items.applyStationType == 3"
							class="card_bg"
							:src="
								items.picture
									? items.picture
									: 'http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/homeSub/images/line_bg2.png'
							"
						/>

						<view class="card_content">
							<view class="card_money">
								<view class="card_money_num">
									￥
									<text>{{ items.couponAmount }}</text>
								</view>
								<view v-if="items.applyStationType == 1" class="card_money_des">通用</view>
								<view v-if="items.applyStationType == 2 || items.applyStationType == 3" class="card_money_des">
									站点专属
								</view>
							</view>
							<view class="card_riqi">
								<view v-if="items.type == 1" class="card_riqi_title">服务费券</view>
								<view v-if="items.type == 2" class="card_riqi_title">电费券</view>
								<view v-if="items.type == 3" class="card_riqi_title">现金券</view>

								<view class="card_riqi_des">满{{ items.meetAmount }}可用</view>
								<view class="card_riqi_riqi">
									<view>
										<image
											class="card_riqi_icon"
											src="http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/homeSub/images/icon1.png"
										/>
										{{ items.receiveTime }}
									</view>
									<view>
										<image
											class="card_riqi_icon"
											src="http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/homeSub/images/icon2.png"
										/>
										{{ items.expireTime }}
									</view>
								</view>
							</view>
							<view class="card_xd">
								{{ items.applyStationTypeStr }}
								<image
									class="card_xd_icon"
									src="http://oos-cn.ctyunapi.cn/front-end/static/marketingImg/homeSub/images/turn.png"
								/>
							</view>
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 价格详情 -->
		<u-popup
			custom-class="price_popup"
			data-type="close"
			mode="bottom"
			position="bottom"
			round="25"
			:show="showPrice"
			@close="closePricePopupVisible"
		>
			<view class="box-info">
				<view class="title">电价收费详情</view>
				<view class="t1">
					<text>收费时段</text>
					<!-- #V2G功能 -->
					<text v-if="isDisCharge">费用(元/度)</text>
					<text v-else>费用(元/度)  =  电费  +  服务费</text>
				</view>

				<!-- 831价格收费详情抽离组件 & #V2G功能 -->
				<priceDetailView :isDisCharge="isDisCharge" :itemData="isDisCharge ? dischargePowerStageDetail : powerStageDetail" />
			</view>
		</u-popup>
	</view>
</template>

<script>
// 'use strict';

import priceDetailView from '@/components/priceDetailView/pileDetailView.vue';
import payMemberCard from '../../../components/payMemberCard/index.vue';

import callPhone from '../../components/callPhone/callPhone.vue';

import gunPriceInfo from '../../components/gunPriceInfo/gunPriceInfo.vue';
const { isChargingAllowed, reservationPages } = require('@/api/private');
// exports.__esModule = true; // homeSub/pages/siteDetail/siteDetail.ts
import placeholPileList from 'homeSub/components/placeholPileList/placeholPileList.vue';
var app = getApp();

var scanCode = require('./../../../utils/scanCode.js');

var https_1 = require('./../../../api/https.js');

const { isCdgj } = require("@/utils/util");

import { getStationCoupon, getStationDiscount } from '../../../api/marketing/stationListApi';
import { isInTime, isOverTime } from './util';
//#ifdef H5
import { nativeCall } from '@/utils/cdgjH5toApp.js';
import { toCDGJWechatMiniLocation } from "@/utils/h5.js";
//#endif

export default {
	components: {
		placeholPileList,

		callPhone,
		payMemberCard,
		gunPriceInfo,
		priceDetailView
	},
	data() {
		return {
			showPrice: false,
			powerStageDetail: [],
			dischargePowerStageDetail: [], // #V2G功能
			sellerNo: app.globalData.sellerNo,
			otherIconListSync: [], // 拿缓存数据
			isToken: false,
			isF: true,
			showDialog: false,
			collectionId: 0,

			siteItemData: {
				name: '',
				stationLabel: [],
				detailsImages: [],
				timeList: [],
				street: '',
				latitude: '',
				longitude: '',
				distance: '',
				notice: '',
				noticeStatus: '',

				gunPriceInfo: {
					superItem: {
						freeGunCount: '',
						gunCount: '',
						currentStartTime: '',
						currentEndTime: '',
						discount: '',
						currentPrice: '',
						currentPowerPrice: '',
						currentServicePrice: ''
					},

					fastItem: {
						freeGunCount: '',
						gunCount: '',
						currentStartTime: '',
						currentEndTime: '',
						discount: '',
						currentPrice: '',
						currentPowerPrice: '',
						currentServicePrice: ''
					},

					slowItem: {
						freeGunCount: '',
						gunCount: '',
						currentStartTime: '',
						currentEndTime: '',
						discount: '',
						currentPrice: '',
						currentPowerPrice: '',
						currentServicePrice: ''
					}
				},

				hasCoupons: '',
				parkingFeeDesc: '',
				managerPhone: '',
				id: '',
				isCollection: false,
				business: false,
				serviceTime: false
			},

			stationGunPriceInfo: {},
			imgList: [],
			id: '',
			stationId: '',
			memberType: '',

			//可用卡券弹窗
			cardCoupon: false,

			cardCouponList: [],

			//站点详情 优惠说明
			stationCouponDetail: {
				enableCouponCount: '',

				consume: {
					activityDetail: {
						id: ''
					}
				},

				single: {
					activityDetail: {
						id: ''
					}
				},

				stationDiscount: {
					activityDetail: {
						id: ''
					}
				}
			},

			ljxfDetail: {
				lowAmount: '',
				bonus: '',
				couponCount: '',
				discount: '',
				integral: '',
				serviceFeeCount: '',
				highestStatus: 0,
				highestBonus: '',
				highestCouponCount: '',
				highestDiscount: '',
				highestIntegral: '',
				highestServiceFeeCount: ''
			},

			dbzkDetail: {
				lowAmount: '',
				bonus: '',
				couponCount: '',
				discount: '',
				integral: '',
				serviceFeeCount: '',
				highestStatus: 0,
				highestBonus: '',
				highestCouponCount: '',
				highestDiscount: '',
				highestIntegral: '',
				highestServiceFeeCount: ''
			},

			zdyhDetail: {
				discountModel: 0,
				discountType: 0,
				singleAmount: '',
				singleReduceAmount: '',
				singleDiscount: '',
				totalAchieveAmount: '',
				totalReduceAmount: '',
				totalDiscount: '',
				socPercentage: '',
				socStartPercentage: '',
				socEndPercentage: '',
				socDiscount: '',
				socReduceAmount: ''
			},

			userTypes: '',
			stationCouponPriceDetail: {},
			showFeedback: true,
			yhsmBox: false,
			platformNo:'',
			isDisCharge: false, // 是否是放电-#V2G功能
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		if (options.stationId) {
			this.stationId = options.stationId
			this.platformNo=options.platformNo || ''
		}
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {
		this.otherIconListSync = uni.getStorageSync('otherIconList');
		this.getStationDetail(this.stationId);
		this.memberType = uni.getStorageSync('memberType').toString();
		this.setData({
			isToken: uni.getStorageSync('token')
		});

		if (uni.getStorageSync('token')) {
			let userInfo = uni.getStorageSync('userInfo');
			console.log(userInfo);
			if (userInfo.memberType == 0) {
				this.userTypes = '1';
			} else {
				this.userTypes = '2';
			}
			this.memberType = uni.getStorageSync('memberType').toString();
			this.getStationCouponDetail();
			this.getStationDiscounts();
		}
	},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {},
	methods: {
		//获取站点详情(查询枪最低价格信息)
		getStationGunPriceDetail: function (gunId) {
			var that = this;
			let getApiUrl = uni.getStorageSync('token') ? https_1.getStationGunDetails : https_1.getStationGunDetailsNotAuth;
			getApiUrl(gunId)
				.then((res) => {
					if (res.code == 0) {
						this.powerStageDetail = res.data?.powerStageDetail || [];

						// #V2G功能
						if (this.isV2GOption) {
							this.dischargePowerStageDetail = res.data?.dischargePowerStageDetail || [];
						}

						that.showPrice = true;
					}
				})
				.catch((err) => {
					uni.showToast({
						title: err,
						icon: 'none',
						duration: 2000
					});
				});
		},
		pricePopupVisible(gunId, isDisCharge = false) {
			this.getStationGunPriceDetail(gunId);
			this.showPrice = true;
			this.isDisCharge = isDisCharge // #V2G功能
		},
		closePricePopupVisible() {
			this.showPrice = false;
		},
		//可用卡券信息
		getStationCouponDetail() {
			const tmp = this;
			getStationCoupon({
				stationId: this.stationId,
				userId: uni.getStorageSync('memberId'),
				userType: this.userTypes
			})
				.then((res) => {
					console.log(res.data, 'kkkkkkkkkkk');
					if (res.code == 200) {
						res.data.forEach((item) => {
							if (item.applyStationType == 1) {
								item.applyStationTypeStr = '所有站点';
							} else if (item.applyStationType == 2) {
								item.applyStationTypeStr = '指定站点';
							} else if (item.applyStationType == 3) {
								item.applyStationTypeStr = '指定条件';
							}
						});
						tmp.setData({
							cardCouponList: res.data
						});
						console.log(this.cardCouponList, 'kkkqqqqq');
					}
				})
				.catch((err) => {
					console.log(err);
				});
		},

		//获取站点优惠说明
		getStationDiscounts() {
			getStationDiscount({
				stationId: this.stationId,
				userId: uni.getStorageSync('memberId'),
				userType: this.userTypes
			})
				.then((res) => {
					console.log(res.data, 'yhsm........');
					if (res.code == 200 && res.data) {
						this.setData({
							stationCouponDetail: res.data,
							ljxfDetail: res.data.consumeRewardMemo,
							dbzkDetail: res.data.singleRewardMemo,
							zdyhDetail: res.data.stationDiscount ? res.data.stationDiscount.serviceFeeDiscountDetail : null,
							yhsmBox: true
						});
						console.log(this.ljxfDetail, '累计消费啊.......');
						console.log(this.dbzkDetail, '单笔折扣啊........');
						console.log(this.zdyhDetail, '站点优惠啊..............');
					} else {
						this.setData({
							yhsmBox: false
						});
					}
				})
				.catch((err) => {
					console.log(err);
				});
		},

		// 可用卡券弹窗
		cardCouponShowPopup() {
			this.setData({
				cardCoupon: true
			});
		},

		cardCouponClose() {
			this.setData({
				cardCoupon: false
			});
		},

		//去优惠券卡券详情
		toCardCoupons(e) {
			console.log(e.currentTarget.dataset);
			uni.navigateTo({
				url: '/homeSub/pages/discount/cardCoupons/cardCoupons?id=' + e.currentTarget.dataset.id
			});
		},

		// 累计消费
		goCumulativeMoney(e) {
			console.log(e.currentTarget.dataset, 'llllllllll');
			uni.navigateTo({
				url: '/homeSub/pages/discount/cumulativeMoney/cumulativeMoney?HD=' + `${e.currentTarget.dataset.hdid}`
			});
		},

		// 单笔折扣
		goSingleMoney(e) {
			console.log(e.currentTarget.dataset, 'dddddddd');
			uni.navigateTo({
				url: '/homeSub/pages/discount/singleMoney/singleMoney?HD=' + `${e.currentTarget.dataset.hdid}`
			});
		},

		// 站点优惠
		goSiteOffers(e) {
			console.log(e.currentTarget.dataset, 'zzzzzzz');
			uni.navigateTo({
				url: '/homeSub/pages/discount/siteOffers/siteOffers?HD=' + `${e.currentTarget.dataset.hdid}`
			});
		},

		// 扫码
		// 处理预约状态为 0 待审核 1 审核通过 的订单
		goScanCode: async function () {

		if(this.sellerNo =='szgx') {
			let todoList = this.reservations.filter((r) => [0, 1].includes(+r.state));
			if (todoList.length == 0) {
				uni.showModal({
					content: '该充电桩需要提前向用户预约提前预约后再使用',
					cancelText: '返回',
					confirmText: '去预约',
					success: (res) => {
						if (res.confirm) {
							this.goAppointment(this.siteItemData);
						}
					}
				});
				return;
			}

			let current = todoList[0];
			if (current.state == 0) {
				return this.toSeeStatus(current);
			} else if (!isInTime(current.reservationStartTime, current.chargingDuration, Date.now())) {
				uni.showModal({
					content: '未到预约时间内，请到预定时间再开始使用',
					cancelText: '返回',
					confirmText: '查看记录',
					success: (res) => {
						if (res.confirm) {
							this.goAppointment(this.siteItemData);
						}
					}
				});
				return;
			}
		}
		
			//#ifdef H5
			if (this.isCdgj()) {
				// 成都公交
				console.log('内嵌H5扫码功能');
				const clientType = uni.getStorageSync('clientType')
				if (clientType == 'WeChat') {
					// 成都公交H5-拉起外部小程序微信扫一扫
					wx.miniProgram.redirectTo({
						url: `/pages_common/pages/otherPay/sanCode`
					});
				} else {
					// 成都公交H5-拉起外部APP扫一扫
					nativeCall('scan', null, (cbData) => {
						// 扫码后返回来的数据
						console.log('-------原生扫码--cbData--------', cbData);
						if (cbData && cbData.url) {
							scanCode.scanCodeFn(decodeURIComponent(cbData.url))
						}
					})
				}
				return
			}
			//#endif
			

			//#ifdef APP-PLUS
			let result = await this.$store.dispatch('requestPermissions', 'CAMERA');
			if (result !== 1) {
				return;
			} else {
				if (uni.getStorageSync('token')) {
					scanCode.stateOfCharge();
				} else {
					scanCode.scanCode();
				}
			}
			//#endif
			//#ifdef MP-WEIXIN || MP-ALIPAY
			if (uni.getStorageSync('token')) {
				scanCode.stateOfCharge();
			} else {
				scanCode.scanCode();
			}
			//#endif
		},

		toSeeStatus(info) {
			uni.navigateTo({
				url: '/homeSub/pages/chargeAppointment/appointmentStatus?status=' + info.state,
				success: (res) => {
					res.eventChannel.emit('data', { ...info, station: this.siteItemData.name });
				}
			});
		},

		showTip: function () {
			uni.showModal({
				title: '信息提示',
				content: '休息中',
				showCancel: false
			});
		},

		//获取站点详情
		getStationDetail: function (stationId) {
			let getStationDetailById = uni.getStorageSync('token')
				? https_1.getStationDetailByIdNew
				: https_1.getStationDetailByIdNotAuth;
			var that = this;
			getStationDetailById({
				stationId: stationId,
				latitude: uni.getStorageSync('latitude'),
				longitude: uni.getStorageSync('longitude')
			}).then((res) => {
				if (this.sellerNo == 'szgx') {
					this.isChargingAllowed(res.data);
					this.reservationPages();
				}

				if (res.code == 0) {
					res.data.noticeStatus = res.data?.notice?.length >= 44 ? true : false;
					//值小数点大于4位就保留4位小数
					if (res.data.gunPriceInfo.fastItem) {
						if (
							String(res.data.gunPriceInfo.fastItem.currentPrice).split('.').length > 1 &&
							String(res.data.gunPriceInfo.fastItem.currentPrice).split('.')[1].length >= 4
						) {
							res.data.gunPriceInfo.fastItem.currentPrice = Number(res.data.gunPriceInfo.fastItem.currentPrice).toFixed(
								4
							);
						}
					}
					if (res.data.gunPriceInfo.slowItem) {
						if (
							String(res.data.gunPriceInfo.slowItem.currentPrice).split('.').length > 1 &&
							String(res.data.gunPriceInfo.slowItem.currentPrice).split('.')[1].length >= 4
						) {
							res.data.gunPriceInfo.slowItem.currentPrice = Number(res.data.gunPriceInfo.slowItem.currentPrice).toFixed(
								4
							);
						}
					}
					if (res.data.gunPriceInfo.superItem) {
						if (
							String(res.data.gunPriceInfo.superItem.currentPrice).split('.').length > 1 &&
							String(res.data.gunPriceInfo.superItem.currentPrice).split('.')[1].length >= 4
						) {
							res.data.gunPriceInfo.superItem.currentPrice = Number(
								res.data.gunPriceInfo.superItem.currentPrice
							).toFixed(4);
						}
					}

					// #V2G功能
					const dischargeItem = res.data.gunPriceInfo.dischargeItem
					if(that.isV2GOption && dischargeItem){
						if(String(dischargeItem.currentPrice).split(".").length>1&&String(dischargeItem.currentPrice).split(".")[1].length>=4){
							dischargeItem.currentPrice = Number(dischargeItem.currentPrice).toFixed(4)
						}
					}

					res.data.picArr = res.data.picArr || '[]';
					if (res.data.picArr) {
						res.data.picArr = JSON.parse(res.data.picArr);
					}

					(that.siteItemData = res.data), (that.siteItemData.tagList = that.siteItemData.tagList);
					(that.imgList = res.data.detailsImages), (that.id = res.data.id);
					that.platformNo=res.data.equipChannelId || ''

					//页面加载最慢的请求结束后再显示
					that.pageApiObj = true;
				}
			});
		},

		reservationPages() {
			reservationPages({ current: 1, pageSize: 10 }).then((res) => {
				this.reservations = res.data.records.filter((r) => isOverTime(r.reservationStartTime, r.chargingDuration));
				console.log('reservations: ', this.reservations);
			});
		},

		isChargingAllowed(data) {
			isChargingAllowed({ pileId: data.pileId }).then((res) => (this.chargingAllowData = res.data));
		},

		//附近站点
		goNearbyStations: function (e) {
			var stationsStreet = e.currentTarget.dataset.name;
			uni.redirectTo({
				url: '/packageFunctional/sitelist/sitelist?stationsStreet=' + stationsStreet
			});
		},

		//取消-弹窗
		onClick_1: function () {
			this.showDialog = false;
		},

		//调起-弹窗
		cancelCollection: function (e) {
			var that = this;
			app.globalData.CHECK_LOGIN(function () {
				(that.collectionId = e.currentTarget.dataset.id), (that.showDialog = true);
			});
		},

		//确定取消收藏-弹窗
		onClick_2: function () {
			var that = this;
			https_1.cancelCollectStation(this.collectionId).then(function (res) {
				if (res.code == 0) {
					var data = that.siteItemData;
					data.isCollection = false;
					(that.siteItemData = data), (that.showDialog = false);
				}
			});
		},

		//收藏
		collection: function (e) {
			var that = this;
			app.globalData.CHECK_LOGIN(function () {
				var id = e.currentTarget.dataset.id;
				https_1.collectStation(id).then(function (res) {
					if (res.code == 0) {
						var data = that.siteItemData;
						data.isCollection = true;
						(that.siteItemData = data), (that.showDialog = false);
					}
				});
			});
		},

		//跳转卡券中心
		goCardVoucher: function () {
			// uni.navigateTo({
			//     url: '../../../mine/pages/cardVoucher/cardVoucher'
			// });

			console.log(this.marketingSwitch);
			if (this.marketingSwitch) {
				console.log('营销获客挂了,走7100逻辑');
				uni.navigateTo({
					url: '../../../mine/pages/cardVoucher/cardVoucher'
				});
			} else {
				console.log('营销获客正常,走外包8081逻辑');
				uni.navigateTo({
					url: '../../../mine/pages/cardVoucherYx/cardVoucherYx'
				});
			}
		},

		//反馈
		goProblemFeedback: function () {
			// uni.navigateTo({
			//     url: '../../../mine/pages/problemFeedback/problemFeedback?feedbackType=other' + '&stationId=' + this.id
			// });
			uni.navigateTo({
				url: '../../../mine/pages/customer/customer'
			});
		},

		call: function () {
			this.$refs.showCustomerPup.open();
		},

		onCloseCustomer: function () {
			this.$refs.showCustomerPup.close();
		},

		//客服电话
		callCustomer: async function () {
			this.$refs.showCustomerPup.close();
			//#ifdef APP-PLUS
			let result = await this.$store.dispatch('requestPermissions', 'CALL_PHONE');
			if (result !== 1) {
				return;
			} else {
				uni.makePhoneCall({
					phoneNumber: this.siteItemData.managerPhone
				});
			}
			//#endif
			//#ifdef MP-WEIXIN
			uni.makePhoneCall({
				phoneNumber: this.siteItemData.managerPhone
			});
			//#endif
		},

		callNative(params) {
      nativeCall("openMap", params);
    },

		// 导航
		goAddress: function (e) {
			// console.log("导航",e)
			var latitude = parseFloat(e.currentTarget.dataset.latitude);
			var longitude = parseFloat(e.currentTarget.dataset.longitude);
			var name = e.currentTarget.dataset.name;
			var street = e.currentTarget.dataset.street;

			var clientType = uni.getStorageSync("clientType");

      // 如果是APP端，则调起原生地图, 目前只有 H5 内嵌
			// #ifdef H5 
      if (clientType == "APP" && isCdgj()) {
        this.callNative({
          lat: latitude,
          lng: longitude,
          address: street,
        });
        return;
      } else if (clientType == "WeChat" && this.isCdgj()) {
        toCDGJWechatMiniLocation({
          lat: latitude,
          lng: longitude,
          address: street,
        })
				return;
      }
			// #endif

			uni.openLocation({
				latitude: latitude,
				longitude: longitude,
				name: name,
				address: street
			});
		},

		//图片预览
		seeImg: function (e) {
			var indx = e.currentTarget.dataset.index; // 找到点击图片的索引位置

			uni.previewImage({
				current: this.imgList[indx],
				urls: this.imgList // 需要预览的图片http链接列表
			});
		},

		//展开  收起
		change: function () {
			var that = this;
			that.isF = !that.isF;
		},

		//价格详情
		goPriceDetail (disCharge = false) {
			let path = '/echartsPages/pages/priceDetail/priceDetail?stationId=' + this.stationId + "&platformNo=" + this.platformNo

			// 
			if (this.isV2GOption && disCharge) {
				path = path + `&disCharge=${disCharge}`
			}

			// #V2G功能
			uni.navigateTo({
				url: path
			});
		},

		goAppointment(info) {
			uni.navigateTo({
				url: `/homeSub/pages/chargeAppointment/chargeAppointment?stationId=${this.stationId}&name=${info.name}&pileId=${info.pileId}&pileName=${info.pileName}`
			});
		}
	}
};
</script>
<style lang="less" scoped>
@import url('./siteDetail.less');

// 831价格展示
@import url('./siteDetail-discount.less');
</style>
